package com.cloudcc.mobile.bull.presenter.impl;

import com.cloudcc.mobile.basebean.BaseListEntity;
import com.cloudcc.mobile.bull.bean.CheckinHistoryBean;
import com.cloudcc.mobile.bull.bean.MarketBean;
import com.cloudcc.mobile.bull.model.IGongniuCheckHistoryNewModel;
import com.cloudcc.mobile.bull.model.IMarketModel;
import com.cloudcc.mobile.bull.presenter.IMarketPresenter;
import com.cloudcc.mobile.bull.view.IGongniuCheckHistoryNewView;
import com.cloudcc.mobile.bull.view.IMarketView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * <pre>
 *     author : 92152
 *     e-mail : xxx@xx
 *     time   : 2020/07/21
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class MarketPresenter implements IMarketPresenter {
    private IMarketView view;
    private IMarketModel model;

    public MarketPresenter(IMarketView view, IMarketModel model) {
        this.view = view;
        this.model = model;
    }

    @Override
    public void inquireMarketList(Map<String, String> praise) {
//        view.showDialog(true);
        model.inquireMarketList(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseListEntity<MarketBean>>() {
                    @Override
                    public void onCompleted() {
//                        view.showDialog(false);
                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("获取所属市场数据失败:"+e.getMessage());
//                        view.showDialog(false);
                    }

                    @Override
                    public void onNext(BaseListEntity<MarketBean> bean) {
                        view.inquireMarketList(bean);
                    }
                });
    }
}
